package thinkingJava.chapter11;

import java.util.Iterator;

public class IterableClass implements Iterable<String> {
	public String[] words = ("That is the way how we know the earch is banana-shaped").split(" ");

	public Iterator<String> iterator() {
		return new Iterator<String>(){
			private int index = 0;

			public boolean hasNext() {
				return index < words.length;
			}
			public String next() {
				return words[index++];
			}
			public void remove() {
				throw new UnsupportedOperationException();
			}
		};
	}
	public static void main(String[] args) {
		for (String s : new IterableClass()) {
			System.out.print(s + "    ");
		}
	}
}
